package org.pearl.thread.demo.test002;


/**
 * Created by TD on 2021/4/12
 */
public class TicketWindow implements Runnable {

    private static int MAX = 10000;

    private final Object MUTEX = new Object();

    @Override
    public void run() {
        while (true) {
            synchronized (MUTEX) {
                if (MAX > 0) {
                    System.out.println(Thread.currentThread().getName() + "抢到第" + MAX-- + "张票");
                }else {
                    break;
                }
            }
        }
    }
}
